<template>
    <div class="container">
        <a-card title="企业信息">
            <a-tabs type="card" :default-active-key="curTabKey" @change="tabChange">
                <a-tab-pane tab="企业介绍" :key="0">
                    <a-form-model layout="horizontal" ref="tab1form" :rules="tab1Option.formOption.formRules" :model="tab1Option.formOption.formData" labelAlign="left" :labelCol="{span:7}" :wrapperCol="{span:24}">
                        <a-row>
                            <a-row type="flex">
                                <a-col style="width: 20%">
                                    <a-form-model-item :labelCol="{span:5}" style="display: flex" label="联系人：" prop="contacts">
                                        <a-input allowClear style="width: 200px;color: #05b089" v-model="tab1Option.formOption.formData.contacts" placeholder="请选择企业联系人"></a-input>
                                    </a-form-model-item>
                                </a-col>
                                <a-col style="width: 20%">
                                    <a-form-model-item :labelCol="{span:7}" style="display: flex" label="操作人电话：" prop="phone">
                                        <a-input allowClear style="width: 200px;color: #05b089" v-model="tab1Option.formOption.formData.phone" placeholder="请选择企业联系人"></a-input>
                                    </a-form-model-item>
                                </a-col>
                            </a-row>
                            <a-col>
                                <a-form-model-item label="企业介绍：" prop="companyIntroduce">
                                    <div class="editor">
                                        <Toolbar style="border-bottom: 1px solid #ccc;" :editor="editorRef" :defaultConfig="editorConfig.toolbarConfig" :mode="mode" />
                                        <Editor  v-model="tab1Option.formOption.formData.companyIntroduce" :defaultConfig="editorConfig" :mode="mode" @onCreated="handleCreated" />
                                    </div>
                                </a-form-model-item>
                            </a-col>
                        </a-row>
                    </a-form-model>
                    <a-row style="margin-top: 20px">
                        <a-col style="text-align: right">
                            <a-button type="primary" @click="tab1submit">提交</a-button>
                        </a-col>
                    </a-row>
                </a-tab-pane>
                <a-tab-pane tab="证件证书" :key="1">
                    <a-form-model layout="horizontal" ref="tab2form" :rules="tab2Option.formOption.formRules" :model="tab2Option.formOption.formData" labelAlign="left">
                        <a-row>
                            <a-col>
                                <a-form-model-item label="企业logo：" prop="companyLogo">
                                    <Upload v-if="curTabKey==1" :uploadLength="1" :defImgList="[tab2Option.formOption.formData.companyLogo]" @uploadChange="logoUpload"/>
                                    <div class="upload-tips">jpg.png.gif格式.不超过2MB</div>
                                </a-form-model-item>
                            </a-col>
                            <a-col>
                                <a-form-model-item label="企业资质证书：">
                                    <a-button type="default" @click="addCertificateOption.visible = true">添加</a-button>
                                </a-form-model-item>
                            </a-col>
                        </a-row>
                    </a-form-model>
                    <a-row style="margin-top: 20px">
                        <a-col style="text-align: right">
                            <a-button type="primary" @click="tab2submit">提交</a-button>
                        </a-col>
                    </a-row>
                </a-tab-pane>
                <a-tab-pane tab="生产企业" :key="2">
                    <a-form-model layout="inline" ref="tab3form" :rules="tab3Option.formOption.formRulesMain" :model="tab3Option.formOption.formData" labelAlign="left">
                        <a-card title="企业信息">
                                <a-row class="item-box" type="flex">
                                    <a-col :span="8">
                                        <a-form-model-item label="企业名称：" prop="companyName">
                                            <a-input allowClear style="width: 200px;color: #05b089" v-model="tab3Option.formOption.formData.companyName" placeholder="请输入企业名称"></a-input>
                                        </a-form-model-item>
                                    </a-col>
                                    <a-col :span="12">
                                        <a-form-model-item label="生产企业：" prop="companyAbbreviation">
                                            <a-input allowClear style="width: 200px;color: #05b089" v-model="tab3Option.formOption.formData.companyAbbreviation" placeholder="请输入生产企业"></a-input>
                                        </a-form-model-item>
                                    </a-col>
                                </a-row>
                                <a-row class="item-box" type="flex">
                                    <a-col :span="8">
                                        <a-form-model-item label="所在区域：" prop="placeAreaJSON">
                                            <a-cascader  style="width: 200px;color: #05b089"
                                                         v-model="tab3Option.formOption.formData.placeAreaJSON"
                                                         :options="tab3Option.formOption.areaList"
                                                         placeholder="请选择所在区域"></a-cascader>
                                        </a-form-model-item>
                                    </a-col>
                                    <a-col :span="12">
                                        <a-form-model-item label="生产地址：" prop="productionAddress">
                                            <a-input allowClear style="width: 200px;color: #05b089" v-model="tab3Option.formOption.formData.productionAddress" placeholder="请输入生产地址"></a-input>
                                        </a-form-model-item>
                                    </a-col>
                                </a-row>
                            <a-row class="item-box" type="flex">
                                <a-col :span="8">
                                   <a-button type="default" @click="addBusinessLicenseOption.visible = true">修改</a-button>
                                </a-col>
                                <a-col :span="12">
                                    <a-button type="default" @click="productionLicenseOption.visible = true">修改</a-button>
                                </a-col>
                            </a-row>
                                <a-row class="item-box" type="flex">
                                    <a-col :span="8">
                                        <a-form-model-item label="营业执照：">
                                            <a-row type="flex" align="middle">
                                                <a-avatar shape="square" :size="128" :src="companyInfo.businessLicensePicture"/>
                                                <div style="margin-left: 40px">
                                                    <span>{{companyInfo.unifyCode}}</span>
                                                    <div>{{companyInfo.businessTermBegin}}-{{companyInfo.businessTermEnd}}</div>
                                                </div>
                                            </a-row>
                                        </a-form-model-item>
                                    </a-col>
                                    <a-col :span="12">
                                        <a-form-model-item label="生产证书：">
                                            <a-row type="flex" align="middle">
                                                <a-avatar shape="square" :size="128" :src="companyInfo.productionCertificate"/>
                                                <div style="margin-left: 40px">
                                                    <span>{{companyInfo.number}}</span>
                                                    <div>{{companyInfo.scBusinessTermBegin}}-{{companyInfo.scBusinessTermEnd}}</div>
                                                </div>
                                            </a-row>
                                        </a-form-model-item>
                                    </a-col>
                                </a-row>
                                <a-row class="item-box" type="flex">
                                    <a-col :span="8">
                                        <a-form-model-item label="生产企业联系方式：" prop="productionPhone">
                                            <a-input allowClear style="width: 200px;color: #05b089" v-model="tab3Option.formOption.formData.productionPhone" placeholder="请输入生产企业联系方式"></a-input>
                                        </a-form-model-item>
                                    </a-col>
                                </a-row>
                        </a-card>
                        <a-card style="margin-top: 20px" title="法人信息">
                            <a-row class="item-box" type="flex">
                                <a-col :span="8">
                                    <a-form-model-item label="人像面身份证照片：" prop="identityCardPortrait">
                                        <upload v-if="curTabKey==2" :uploadLength="1" :defImgList="[tab3Option.formOption.formData.identityCardPortrait]" @uploadChange="legalPersonIdCardFrontUpload"></upload>
                                        <div class="upload-tips">jpg.png.gif格式.不超过2MB</div>
                                    </a-form-model-item>
                                </a-col>
                            </a-row>
                            <a-row class="item-box" type="flex">
                                <a-col :span="8">
                                    <a-form-model-item label="国徽面身份证照片：" prop="identityCardNationalEmblem">
                                        <upload v-if="curTabKey==2" :uploadLength="1" :defImgList="[tab3Option.formOption.formData.identityCardNationalEmblem]" @uploadChange="legalPersonIdCardBackUpload"></upload>
                                        <div class="upload-tips">jpg.png.gif格式.不超过2MB</div>
                                    </a-form-model-item>
                                </a-col>
                            </a-row>
                        </a-card>
                    </a-form-model>
                    <div style="margin-top: 20px;text-align: right" v-if="$utilCheckPermission(['enterpriseInformationSubmit'])">
                        <a-button type="primary" @click="tab3OptionSubmit">确定</a-button>
                    </div>
                </a-tab-pane>
            </a-tabs>
        </a-card>
        <a-modal :visible="addCertificateOption.visible" :title="addCertificateOption.modalTitle" :confirmLoading="addCertificateOption.confirmLoading" okText="确定" cancelText="取消" @cancel="addCertificateOption.visible = false" @ok="handleOk">
           <a-form-model ref="addCertificateForm" :rules="tab2Option.formOption.formRules" :model="tab2Option.formOption.formData">
               <a-form-model-item label="证书名称" prop="certificateName">
                   <a-input allowClear  v-model="tab2Option.formOption.formData.certificateName" placeholder="请输入证书名称"></a-input>
               </a-form-model-item>
               <a-form-model-item label="营业期限" prop="effectivePeriod">
                   <a-range-picker :locale="locale"  style="width: 100%" v-model="tab2Option.formOption.formData.effectivePeriod" :placeholder="['开始日期','结束日期']"></a-range-picker>
               </a-form-model-item>
               <a-form-model-item label="证书照片" prop="certificatePicture">
                   <upload v-if="addCertificateOption.visible" :uploadLength="1" :defImgList="[tab2Option.formOption.formData.certificatePicture]" @uploadChange="certificateUpload"></upload>
                   <div class="upload-tips">jpg.png.gif格式.不超过2MB</div>
               </a-form-model-item>
               <a-form-model-item label="长期" prop="businessTermLongTime">
                   <a-radio-group v-model="tab2Option.formOption.formData.businessTermLongTime">
                   <a-radio :value="1">是</a-radio>
                   <a-radio :value="0">否</a-radio>
               </a-radio-group>
               </a-form-model-item>
           </a-form-model>
        </a-modal>

        <a-modal :visible="addBusinessLicenseOption.visible" :title="addBusinessLicenseOption.modalTitle" :confirmLoading="addBusinessLicenseOption.confirmLoading" okText="确定" cancelText="取消" @cancel="addBusinessLicenseOption.visible = false" @ok="licenseHandleOk">
            <a-form-model ref="addBusinessLicenseForm" :rules="tab3Option.formOption.formRules1" :model="tab3Option.formOption.formData">
                <a-form-model-item label="营业执照照片" prop="businessLicensePicture">
                    <upload v-if="addBusinessLicenseOption.visible" :uploadLength="1" :defImgList="[tab3Option.formOption.formData.businessLicensePicture]" @uploadChange="businessLicenseUpload"></upload>
                    <div class="upload-tips">jpg.png.gif格式.不超过2MB</div>
                </a-form-model-item>
                <a-form-model-item label="营业期限" prop="yyEffectivePeriod">
                    <a-range-picker :locale="locale"  style="width: 100%" v-model="tab3Option.formOption.formData.yyEffectivePeriod" :placeholder="['开始日期','结束日期']"></a-range-picker>
                </a-form-model-item>
                <a-form-model-item label="统一代码" prop="unifyCode">
                    <a-input allowClear  v-model="tab3Option.formOption.formData.unifyCode" placeholder="请输入编号"></a-input>
                </a-form-model-item>
                <a-form-model-item label="长期" prop="yyBusinessTermLongTime">
                    <a-radio-group v-model="tab3Option.formOption.formData.yyBusinessTermLongTime">
                        <a-radio :value="1">是</a-radio>
                        <a-radio :value="0">否</a-radio>
                    </a-radio-group>
                </a-form-model-item>
            </a-form-model>
        </a-modal>

        <a-modal :visible="productionLicenseOption.visible" :title="productionLicenseOption.modalTitle" :confirmLoading="productionLicenseOption.confirmLoading" okText="确定" cancelText="取消" @cancel="productionLicenseOption.visible = false" @ok="productionLicenseHandleOk">
            <a-form-model ref="productionLicenseForm" :rules="tab3Option.formOption.formRules2" :model="tab3Option.formOption.formData">
                <a-form-model-item label="生产证书照片" prop="productionCertificate">
                    <upload v-if="productionLicenseOption.visible" :uploadLength="1" :defImgList="[tab3Option.formOption.formData.productionCertificate]" @uploadChange="operatingCertificateUpload"></upload>
                    <div class="upload-tips">jpg.png.gif格式.不超过2MB</div>
                </a-form-model-item>
                <a-form-model-item label="营业期限" prop="scEffectivePeriod">
                    <a-range-picker :locale="locale"  style="width: 100%" v-model="tab3Option.formOption.formData.scEffectivePeriod" :placeholder="['开始日期','结束日期']"></a-range-picker>
                </a-form-model-item>
                <a-form-model-item label="编号" prop="number">
                    <a-input allowClear  v-model="tab3Option.formOption.formData.number" placeholder="请输入编号"></a-input>
                </a-form-model-item>
                <a-form-model-item label="长期" prop="scBusinessTermLongTime">
                    <a-radio-group v-model="tab3Option.formOption.formData.scBusinessTermLongTime">
                        <a-radio :value="1">是</a-radio>
                        <a-radio :value="0">否</a-radio>
                    </a-radio-group>
                </a-form-model-item>
            </a-form-model>
        </a-modal>

    </div>
</template>

<script>
import area, {getAreaWords} from '@/utils/area'
import handleRequest from "@/utils/handleRequest";
import {MENU_CONF, toolbarConfig} from "@/utils/wangeditors";
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
import Upload from '@/components/upload.vue';
import nextApi from "@/api/nextApi";
import locale from "ant-design-vue/lib/date-picker/locale/zh_CN";
export default {
    name: "companyInfo",
    components:{
        Editor,
        Toolbar,
        Upload
    },
    data() {
        return {
            locale,
            editorRef: null,
            mode:'default',
            editorConfig: {
                placeholder: '请输入内容...',
                //配置工具栏
                toolbarConfig: toolbarConfig,
                MENU_CONF: MENU_CONF,
            },
            curTabKey:0,
            companyInfo:{},
            tab1Option:{
                formOption:{
                    formData:{
                        contacts:'',
                        phone:'',
                        companyIntroduce:'',
                    },
                    formRules: {
                        contacts:[
                            { required: true, message: '请选择企业联系人', trigger: 'change' },
                        ],
                        phone:[
                            { required: true, message: '请输入操作人电话', trigger: 'blur' },
                        ],
                        companyIntroduce:[
                            { validator:(rules,value,callback)=>{
                                    if(value == '<p><br></p>'){
                                        callback('请输入企业介绍')
                                    }else{
                                        callback()
                                    }
                                }, trigger: 'change' },
                        ]
                    },
                },
            },
            tab2Option:{
                formOption:{
                    formData:{
                        companyLogo:[],
                        effectivePeriod:[],
                        certificatePicture:[],
                        certificateName:'',
                        businessTermBegin:'',
                        businessTermEnd:'',
                        businessTermLongTime:'',
                    },
                    formRules: {
                        effectivePeriod:[
                            { required: true, message: '请选择营业期限', trigger: 'change' },
                        ],
                        companyLogo:[
                            { required: true, message: '请上传企业logo', trigger: 'change' },
                        ],
                        certificatePicture:[
                            { validator:(rules,value,callback)=>{
                                if(this.tab2Option.formOption.formData.certificatePicture.length){
                                    callback()
                                }else{
                                    callback('请上传证书照片')
                                }
                            }, trigger: 'change' },
                        ],
                        certificateName:[
                            { required: true, message: '请输入证书名称', trigger: 'blur' },
                        ],
                        businessTermLongTime:[
                            { required: true, message: '请选择长期', trigger: 'change' },
                        ]
                    }
                }
            },
            tab3Option:{
                formOption:{
                    areaList:[],
                    formData:{
                        companyName:'',
                        companyAbbreviation:'',
                        placeAreaJSON:[],
                        productionAddress:'',
                        //营业执照弹窗
                        businessLicensePicture:[],
                        yyEffectivePeriod:[],//营业期限数组 自用
                        yyBusinessTermBegin:'',
                        yyBusinessTermEnd:'',
                        yyBusinessTermLongTime:true,
                        unifyCode:'',
                        //生产证书弹窗
                        productionCertificate:[],
                        number:'',
                        scEffectivePeriod:[],//生产期限数组 自用
                        scBusinessTermBegin:'',
                        scBusinessTermEnd:'',
                        scBusinessTermLongTime:true,
                        productionPhone:'',
                        identityCardPortrait:[],//身份证正面
                        identityCardNationalEmblem:[],//身份证反面
                        corporateRepresentative:'',//法人代表
                        identityCard:'',//身份证
                        frBusinessTermBegin:'',//法人开始时间
                        frBusinessTermEnd:'',//法人结束时间
                        frBusinessTermLongTime:'',//法人长期
                        legalPersonPhone:''//法人电话
                    },
                    formRulesMain:{
                        companyName:[
                            { required: true, message: '请输入企业名称', trigger: 'blur' },
                        ],
                        companyAbbreviation:[
                            { required: true, message: '请输入企业简称', trigger: 'blur' },
                        ],
                        placeAreaJSON:[
                            { required: true, message: '请选择所在地', trigger: 'change' },
                        ],
                        productionAddress:[
                            { required: true, message: '请输入生产地址', trigger: 'blur' },
                        ],
                        identityCardPortrait:[
                            { required: true, message: '请上传身份证正面', trigger: 'change' },
                        ],
                        identityCardNationalEmblem:[
                            { required: true, message: '请上传身份证反面', trigger: 'change' },
                        ],
                    },
                    formRules1: {
                        businessLicensePicture:[
                            { validator:(rules,value,callback)=>{
                                    if(this.tab3Option.formOption.formData.businessLicensePicture.length){
                                        callback()
                                    }else{
                                        callback('请上传营业执照照片')
                                    }
                                }, trigger: 'change' },
                        ],
                        effectivePeriod:[
                            { required: true, message: '请选择营业期限', trigger: 'change' },
                        ],
                        unifyCode:[
                            { required: true, message: '请输入统一代码', trigger: 'blur' },
                        ],
                        yyBusinessTermLongTime:[
                            { required: true, message: '请选择长期', trigger: 'change' },
                        ],
                    },
                    formRules2: {
                        productionCertificate:[
                            { validator:(rules,value,callback)=>{
                                    if(this.tab3Option.formOption.formData.productionCertificate.length){
                                        callback()
                                    }else{
                                        callback('请上传证书照片')
                                    }
                                }, trigger: 'change' },
                        ],
                        scEffectivePeriod:[
                            { required: true, message: '请选择期限', trigger: 'change' },
                        ],
                        number:[
                            { required: true, message: '请输入编号', trigger: 'blur' },
                        ],
                        scBusinessTermLongTime:[
                            { required: true, message: '请选择长期', trigger: 'change' },
                        ],
                    }

                },


            },
            addCertificateOption:{
                visible: false,
                modalTitle:'资质证书',
                confirmLoading:false,
            },
            addBusinessLicenseOption:{
                visible: false,
                modalTitle:'营业执照',
                confirmLoading:false,
            },
            productionLicenseOption:{
                visible: false,
                modalTitle:'生产证书',
                confirmLoading:false,
            },


        }
    },
    mounted() {
        this.tab3Option.formOption.areaList = area
        this.getData()
    },
    methods: {
        // effectivePeriodChange(time){
        //     this.tab2Option.formOption.formData.businessTermBegin = time[0].format('YYYY-MM-DD')
        //     this.tab2Option.formOption.formData.businessTermEnd = time[1].format('YYYY-MM-DD')
        //     console.log( this.tab2Option.formOption.formData)
        // },
        tabChange(i){
            this.curTabKey = i
        },
        async getData(){
            const res = await nextApi.getEnterpriseInfo();
            console.log(res)
            if(res.code == 200){
                this.companyInfo = res.data

                this.tab1Option.formOption.formData.id = this.companyInfo.id
                this.tab2Option.formOption.formData.id = this.companyInfo.id
                this.tab3Option.formOption.formData.id = this.companyInfo.id
                /**
                 * @description回显表单数据
                 * **/
                this.tab1Option.formOption.formData.contacts = this.companyInfo.contacts
                this.tab1Option.formOption.formData.phone = this.companyInfo.phone
                this.tab1Option.formOption.formData.companyIntroduce = this.companyInfo.companyIntroduce

                this.tab2Option.formOption.formData.companyLogo = this.companyInfo.companyLogo
                this.tab2Option.formOption.formData.certificateName = this.companyInfo.certificateName
                this.tab2Option.formOption.formData.certificatePicture = this.companyInfo.certificatePicture
                this.tab2Option.formOption.formData.businessTermBegin = this.companyInfo.businessTermBegin
                this.tab2Option.formOption.formData.businessTermEnd = this.companyInfo.businessTermEnd
                this.tab2Option.formOption.formData.effectivePeriod = [this.companyInfo.businessTermBegin, this.companyInfo.businessTermEnd]
                this.tab2Option.formOption.formData.businessTermLongTime = this.companyInfo.businessTermLongTime

                //生产企业表单外层
                this.tab3Option.formOption.formData.companyName = this.companyInfo.companyName
                this.tab3Option.formOption.formData.companyAbbreviation = this.companyInfo.companyAbbreviation
                this.tab3Option.formOption.formData.placeAreaJSON = this.companyInfo.placeAreaJSON
                this.tab3Option.formOption.formData.productionAddress = this.companyInfo.productionAddress
                this.tab3Option.formOption.formData.productionPhone = this.companyInfo.productionPhone
                this.tab3Option.formOption.formData.identityCardPortrait = this.companyInfo.identityCardPortrait
                this.tab3Option.formOption.formData.identityCardNationalEmblem = this.companyInfo.identityCardNationalEmblem
                //生产企业-营业执照表单
                this.tab3Option.formOption.formData.businessLicensePicture = this.companyInfo.businessLicensePicture
                this.tab3Option.formOption.formData.yyBusinessTermBegin = this.companyInfo.yyBusinessTermBegin
                this.tab3Option.formOption.formData.yyBusinessTermEnd = this.companyInfo.yyBusinessTermEnd
                this.tab3Option.formOption.formData.yyEffectivePeriod = [this.companyInfo.yyBusinessTermBegin, this.companyInfo.yyBusinessTermEnd]
                this.tab3Option.formOption.formData.yyBusinessTermLongTime = this.companyInfo.yyBusinessTermLongTime
                this.tab3Option.formOption.formData.unifyCode = this.companyInfo.unifyCode
                //生产企业-生产许可证表单
                this.tab3Option.formOption.formData.productionCertificate = this.companyInfo.productionCertificate
                this.tab3Option.formOption.formData.scBusinessTermBegin = this.companyInfo.scBusinessTermBegin
                this.tab3Option.formOption.formData.scBusinessTermEnd = this.companyInfo.scBusinessTermEnd
                this.tab3Option.formOption.formData.scEffectivePeriod = [this.companyInfo.scBusinessTermBegin, this.companyInfo.scBusinessTermEnd]
                this.tab3Option.formOption.formData.scBusinessTermLongTime = this.companyInfo.scBusinessTermLongTime
                this.tab3Option.formOption.formData.number = this.companyInfo.number

            }

        },
        //资质证书弹窗确定
        handleOk(){
            this.$refs.addCertificateForm.validate(async valid => {
                if (!valid) return
                console.log(this.tab2Option.formOption.formData)
                if(typeof this.tab2Option.formOption.formData?.effectivePeriod[0] !== 'string'){
                    this.tab2Option.formOption.formData.businessTermBegin = this.tab2Option.formOption.formData.effectivePeriod[0].format('YYYY-MM-DD')
                    this.tab2Option.formOption.formData.businessTermEnd = this.tab2Option.formOption.formData.effectivePeriod[1].format('YYYY-MM-DD')
                }
                // delete this.tab2Option.formOption.formData.effectivePeriod
                const res = await nextApi.editEnterpriseInfo(this.tab2Option.formOption.formData)
                if(res.code == 200){
                    this.$message.success(res.msg)
                    this.addCertificateOption.visible = false
                    this.getData()
                }
            })
        },
        //营业执照弹窗确定
        licenseHandleOk(){
            this.$refs.addBusinessLicenseForm.validate(async valid => {
                if (!valid) return
                if(typeof this.tab3Option.formOption.formData.yyEffectivePeriod[0] !== 'string'){
                    this.tab3Option.formOption.formData.yyBusinessTermBegin = this.tab3Option.formOption.formData.yyEffectivePeriod[0].format('YYYY-MM-DD')
                    this.tab3Option.formOption.formData.yyBusinessTermEnd = this.tab3Option.formOption.formData.yyEffectivePeriod[1].format('YYYY-MM-DD')
                }
                // delete this.tab3Option.formOption.formData.yyEffectivePeriod
                const res = await nextApi.editEnterpriseInfo(this.tab3Option.formOption.formData)
                if(res.code == 200){
                    this.$message.success(res.msg)
                    this.addBusinessLicenseOption.visible = false
                    this.getData()
                }
            })
        },
        //生产证书弹窗确定
        productionLicenseHandleOk(){
            this.$refs.productionLicenseForm.validate(async valid => {
                if (!valid) return
                if(typeof this.tab3Option.formOption.formData.scEffectivePeriod[0] !== 'string'){
                    this.tab3Option.formOption.formData.scBusinessTermBegin = this.tab3Option.formOption.formData.scEffectivePeriod[0].format('YYYY-MM-DD')
                    this.tab3Option.formOption.formData.scBusinessTermEnd = this.tab3Option.formOption.formData.scEffectivePeriod[1].format('YYYY-MM-DD')
                }
                // delete this.tab3Option.formOption.formData.yyEffectivePeriod
                console.log(this.tab3Option.formOption.formData)
                const res = await nextApi.editEnterpriseInfo(this.tab3Option.formOption.formData)
                if(res.code == 200){
                    this.$message.success(res.msg)
                    this.productionLicenseOption.visible = false
                    this.getData()
                }
            })
        },
        handleCreated(editor) {
            this.editorRef = editor // 记录 editor 实例
        },
        tab1submit(){
            this.$refs.tab1form.validate(async valid => {
                if (!valid) return
                console.log(this.tab1Option.formOption.formData)
                const res = await nextApi.editEnterpriseInfo(this.tab1Option.formOption.formData)
                if(res.code == 200){
                    this.$message.success(res.msg)
                    this.getData()
                }
            })
        },

        tab2submit(){
            this.$refs.tab2form.validate(async valid => {
                if (!valid) return
                console.log(this.tab2Option.formOption.formData)
                const res = await nextApi.editEnterpriseInfo(this.tab2Option.formOption.formData)
                if(res.code == 200){
                    this.$message.success(res.msg)
                    this.getData()
                }
            })
        },
        tab3OptionSubmit(){
            this.$refs.tab3form.validate(async valid => {
                if (!valid) return
                const res = await nextApi.editEnterpriseInfo(this.tab3Option.formOption.formData)
                if(res.code == 200){
                    this.$message.success(res.msg)
                    this.getData()
                }
            })
        },
        //图片上传器完成上传后赋值图片地址的方法们
        logoUpload(images){
            console.log(images)
            if(images.length){
                this.tab2Option.formOption.formData.companyLogo = images[0].url
            }else{
                this.tab2Option.formOption.formData.companyLogo = ''
            }
        },
        certificateUpload(images){
            //只传图片url
            if(images.length){
                this.tab2Option.formOption.formData.certificatePicture = images[0].url
            }else{
                this.tab2Option.formOption.formData.certificatePicture = ''
            }
        },
        businessLicenseUpload(images){
            if(images.length){
                this.tab3Option.formOption.formData.businessLicensePicture = images[0].url
            }else{
                this.tab3Option.formOption.formData.businessLicensePicture = ''
            }
        },
        operatingCertificateUpload(images){
            if(images.length){
                this.tab3Option.formOption.formData.productionCertificate = images[0].url

            }else{
                this.tab3Option.formOption.formData.productionCertificate = ''
            }
        },
        legalPersonIdCardFrontUpload(images){
            if(images.length){
                this.tab3Option.formOption.formData.identityCardPortrait = images[0].url
            }else{
                this.tab3Option.formOption.formData.identityCardPortrait = ''
            }
        },
        legalPersonIdCardBackUpload(images){
            if(images.length){
                this.tab3Option.formOption.formData.identityCardNationalEmblem = images[0].url
            }else{
                this.tab3Option.formOption.formData.identityCardNationalEmblem = ''
            }
        },


    },
}
</script>
<style scoped lang="scss">
.container{
    padding: 20px;
}
.info-box{
    padding: 10px;
    border: 1px solid rgba(70, 70, 70, 0.11);
}
.item-box{
    margin: 20px 0;
}
</style>
